package com.taxsystem.fangzicheng.main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.taxsystem.fangzicheng.governmentservice.GovernmentServiceAcitvity;
import com.main.taxsystem.R;
import com.taxsystem.fangzicheng.taxpolicy.TaxPolicyActivity;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;


public class MainActivity extends Activity {

	private GridView gridView;
	 private int res[] = new int[] {R.drawable.swzc,R.drawable.zwfw };
	 Intent intent;
	 int item = 0;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main1);
		gridView = (GridView) findViewById(R.id.gridView1);
       List<Map<String, Object>> data = new ArrayList<Map<String,Object>>();
       for(int i=0;i<res.length;i++){
       Map<String,Object> map = new HashMap<String, Object>();
          map.put("imageView",res[i]);
          data.add(map);
       }
      SimpleAdapter simpleAdapter = new SimpleAdapter(this, data,R.layout.main1_cell, new String[]{"imageView"}, new int[]{R.id.imageView1});
      gridView.setAdapter(simpleAdapter);
      gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> parent, View v,
					int position, long id) {
				item = position + 1;
				switch (item) {
				case 1:
					intent = new Intent();
					/* 指定intent要启动的类 */
					intent.setClass(MainActivity.this,TaxPolicyActivity.class);
					/* 启动一个新的Activity */
					startActivity(intent);
					break;
				case 2:
					intent = new Intent();
					/* 指定intent要启动的类 */
					intent.setClass(MainActivity.this,GovernmentServiceAcitvity.class);
					/* 启动一个新的Activity */
					startActivity(intent);
					break;
				}
			}
		});
	}
}
